package puly.arr;

public class Adult {
    private String name;
    public Adult(){

    }
    public Adult(String name){
        this.name=name;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
    public void adultDrive(Car car){
        if(car instanceof Sedan){
            System.out.println("姓名："+getName()+"正在行驶"+((Sedan) car).getChassis()+"底盘的轿车");
        } else if (car instanceof Suv) {
            System.out.println("姓名："+getName()+"正在行驶"+((Suv) car).getChassis()+"底盘的SUV");

        }

    }
    public void drive2(Car car,Road road){
        if(car instanceof Sedan && road instanceof FreeWay){
            System.out.println("姓名："+getName()+"正驾驶"+((Sedan) car).getChassis()+"底盘的轿车行驶在"+"名称为:"+((FreeWay) road).getName()+"限速为:"+((FreeWay) road).getSpeedLimit()+"KM/H的高速路上");

        } else if (car instanceof Sedan && road instanceof UrbanExpressway) {

            System.out.println("姓名："+getName()+"正驾驶"+((Sedan) car).getChassis()+"底盘的轿车行驶在"+"名称为:"+((UrbanExpressway) road).getName()+"限速为:"+((UrbanExpressway) road).getSpeedLimit()+"KM/H的城市快速路上");
        } else if (car instanceof Suv && road instanceof FreeWay) {
            System.out.println("姓名："+getName()+"正驾驶"+((Suv) car).getChassis()+"底盘的SUV行驶在名称为："+((FreeWay)road).getName()+"限速为:"+((FreeWay) road).getSpeedLimit()+"KM/H的高速路上");


        } else if (car instanceof Suv&& road instanceof UrbanExpressway) {
            System.out.println("姓名："+getName()+"正驾驶"+((Suv)car).getChassis()+"底盘的Suv行驶在名称为："+((UrbanExpressway)road).getName()+"，限速为："+((UrbanExpressway) road).getSpeedLimit()+"KM/H的城市快速路上");

        }else{
            System.out.println("姓名："+getName()+"正驾驶");
        }
    }
}
